/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package test2.test2;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.List;
import modele.DAO;
import modele.Medecin;

/**
 *
 * @author sio
 */
public class ListMedActivity extends ListActivity {
    @Override
    public void onCreate(Bundle icicle){
        super.onCreate(icicle);
        setContentView(R.layout.listmedactivity);
        Intent inter=getIntent();
        String num=inter.getStringExtra("leNum");
        
        List<Medecin> lesMeds=DAO.getLesMeds(num);
        MedAdapter adapter = new MedAdapter(lesMeds,this);
        setListAdapter(adapter);
    }
    
    public void onListItemClick(ListView l, View v, int position, long id){
        Medecin leMed = (Medecin)l.getItemAtPosition(position);
        String tel=leMed.getTel();
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + tel));
        startActivity(callIntent);
    }
}
